package StudyCode.summary.mycollection;

import java.util.HashMap;
import java.util.Map;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsANewMapWithNoNull {
	public static <A, B> Map<A, B> removeNullEntries(Map<A, B> map) {

		HashMap<A, B> result = new HashMap<A, B>();

		for (Map.Entry<A, B> entry : map.entrySet()) {
			if (entry.getValue() != null) {
				result.put(entry.getKey(), entry.getValue());
			}
		}
		return result;
	}
}
